URL = "ftp://ftp.cs.man.ac.uk/pub/toby/gpc/gpc%(VERSION)s.zip"
DESCRIPTION = "General Polygon Clipper Library"
DEPENDS = None
VERSIONS = ["231", "232", "232-release"]
DEFAULT_VERSION = "232-release" 

import os
from source.builders import GenericBuilder
class GpcBuilder( GenericBuilder ):

  def make(self):
    os.chdir( self.extractedpath )
    if self.machine.isLinux():
      flags = "-g -o gpcd.so" if self.debug else "-O2 -o gpc.so"
      self.execute( "gcc gpc.c " + flags + " -shared -fPIC" )

    if self.machine.isWindows():
      self.execute( "cl /O2 /LD gpc.c" )

  def install(self):
    os.chdir( self.extractedpath )

    name = "gpc.so" if self.machine.isLinux() else "gpc.dll"
    if self.debug:
      name = "gpcd.so" if self.machine.isLinux() else "gpc.dll"

    self.copyfile( name, self.targetpath() )

BUILDER = GpcBuilder

